#pragma once
#include <opencv\cv.h>
#include <opencv2\highgui\highgui.hpp>
#include <iostream>
#include <fstream>
using namespace std;
using namespace cv;
struct PoINT
{
	int x;
	int y;
};
class Lines
{
public:
	PoINT start[100];
	PoINT end[100];
	int n;
	Lines(void)
	{
		n =0;
	}

	~Lines(void)
	{
	}
	void Add(int x1,int y1,int x2,int y2)
	{
		start[n].x = x1;
		start[n].y = y1;
		end[n].x = x2;
		end[n].y = y2;
		n++;
	}

	void ShowAll()
	{
		for(int i =0;i<n;i++)
			cout << start[i].x << " " << start[i].y << " : " << end[i].x << " " << end[i].y << endl;
	}
	void DrawAllLine(IplImage* image)
	{
		for(int i =0;i<n;i++)
			cvLine(image,cvPoint(start[i].x,start[i].y),cvPoint(end[i].x,end[i].y),cvScalar(255,0,0),3);
		cvShowImage("image",image);
	}
	void Save(char* name)
	{
		fstream f;
		f.open(name,ios::app);
		f << n << endl;
		for(int i =0;i<n;i++)
			f << start[i].x << " " << start[i].y << " " << end[i].x << " " << end[i].y << endl;
		f.close();
	}
	void Load(char* name)
	{
		fstream f;
		f.open(name,ios::in);
		f >> n;
		for(int i =0;i<n;i++)
		{
			//f << start[i].x << " " << start[i].y << " " << end[i].x << " " << end[i].y << endl;
			f >> start[i].x;
			f >> start[i].y;
			f >> end[i].x;
			f >> end[i].y;
		}
		f.close();
	}
};

